package com.gduf.bbl.service.impl;

import com.gduf.bbl.common.utils.PageUtils;
import com.gduf.bbl.common.utils.Query;
import com.gduf.bbl.common.utils.R;
import org.springframework.stereotype.Service;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;


import com.gduf.bbl.dao.UserinfoDao;
import com.gduf.bbl.entity.UserinfoEntity;
import com.gduf.bbl.service.UserinfoService;


@Service("userinfoService")
public class UserinfoServiceImpl extends ServiceImpl<UserinfoDao, UserinfoEntity> implements UserinfoService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        IPage<UserinfoEntity> page = this.page(
                new Query<UserinfoEntity>().getPage(params),
                new QueryWrapper<UserinfoEntity>()
        );

        return new PageUtils(page);
    }

    @Override
    public R sq(String name, String formId, String s,String areaId,String userId) {
        final UserinfoEntity userinfoEntity = new UserinfoEntity();
        userinfoEntity.setCert(s);
        userinfoEntity.setAreaId(Integer.parseInt(areaId));
        userinfoEntity.setUserId(Integer.parseInt(userId));
        userinfoEntity.setName(name);
        userinfoEntity.setFormId(formId);

        int i = this.baseMapper.insert(userinfoEntity);
        if(i > 0){
            return R.ok();
        }else{
            return R.error();
        }


    }

}